package com.leimo.demo;

import java.util.List;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.extension.LoadingStrategy;
import org.apache.dubbo.rpc.Filter;

public class ActivatedExtensionTest {

  public static void main(String[] args) {
    String url = "dubbo://172.16.1.78:20880/com.leimo.demo.DemoService?anyhost=true&application=consumer-of-hello-world&cache=lru&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=test&init=false&interface=com.leimo.demo.DemoService&metadata-type=remote&methods=methodTimeout,sayHello&monitor=dubbo%3A%2F%2F127.0.0.1%3A2181%2Forg.apache.dubbo.registry.RegistryService%3Fapplication%3Dconsumer-of-hello-world%26client%3Dcurator%26dubbo%3D2.0.2%26pid%3D3582%26protocol%3Dregistry%26qos.enable%3Dfalse%26qos.port%3D33333%26refer%3Dapplication%253Dconsumer-of-hello-world%2526dubbo%253D2.0.2%2526interface%253Dorg.apache.dubbo.monitor.MonitorService%2526pid%253D3582%2526qos.enable%253Dfalse%2526qos.port%253D33333%2526register.ip%253D172.16.1.78%2526release%253D2.7.7%2526timestamp%253D1591767901179%26registry%3Dzookeeper%26release%3D2.7.7%26timestamp%3D1591767901177&organization=leimo&owner=wxl&pid=3582&qos.enable=false&qos.port=33333&register.ip=172.16.1.78&release=2.7.7&remote.application=hello-world-app&revision=1.0&sayHello.loadbalance=random&side=consumer&sticky=false&timestamp=1591757192069&version=1.0&weight=200";
    /**
     * CommonConstants.REFERENCE_FILTER_KEY, CommonConstants.CONSUMER
     */
    List<Filter> filters = ExtensionLoader
        .getExtensionLoader(Filter.class).getActivateExtension(URL.valueOf(url), CommonConstants.REFERENCE_FILTER_KEY, CommonConstants.CONSUMER);
//    System.out.println(filters);

    List<LoadingStrategy> loadingStrategies = ExtensionLoader.getLoadingStrategies();
    System.out.println(loadingStrategies);
  }
}
